package com.zhangdi.demo.es.utils;

/**
 * Created by zhangdi on 2021/01/21 21:13:34.
 */
public class NumberUtils {
    public static double parseDoubleTry(String s) {
        //TODO 校验是不是数字
        if (StringUtils.isEmptyNone(s)) {
            return 0;
        }

        double num = 0;
        try {
            num = Double.parseDouble(s);
        } catch (NumberFormatException e){
            e.printStackTrace();
        }

        return num;
    }

    public static float parseFloatTry(String s) {
        //TODO 校验是不是数字
        if (StringUtils.isEmptyNone(s)) {
            return 0;
        }

        float num = 0;
        try {
            num = Float.parseFloat(s);
        } catch (NumberFormatException e){
            e.printStackTrace();
        }

        return num;
    }
}
